package com.changgou.goods.feign;

import com.changgou.entity.Result;
import com.changgou.goods.pojo.Sku;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@FeignClient(name = "goods")//从Eureka中获取到服务应用名称为goods的应用,然后去到url将url和接口中的地址值拼接在一起,从而实现微服务的调用
public interface SkuFeign {
    /**
     * 根据spuId来搜索商品
     *
     * @param spuId
     * @return
     */
    @GetMapping("/sku/spu/{spuId}")
    List<Sku> findSkuListBySpuId(@PathVariable String spuId);


    @GetMapping("/sku/{id}")
    public Result<Sku> findById(@PathVariable String id);

    @PostMapping("/sku/decr/count")
    Result decrCount(@RequestParam("username") String username);
}
